<?php
namespace app\admin\controller;
use think\Db;
//租客管理
class Users extends Base{
	//用户列表
	public function user_list(){
		$type		=!empty(input('type')) ? input('type') : '';    //用户身份
		$phone		=!empty(input('phone')) ? input('phone') : ''; 
    	$stime		=!empty(input('stime')) ? input('stime') : 0;
    	$etime		=!empty(input('etime')) ? input('etime') : 0;
		$map['del']=['NEQ',1];	//没有绑定商品
		
		if(!empty($type)){
			$map['type']=['EQ',$type];	//根据生成批次筛选
		}
		if(!empty($phone)){
			$map['phone']=['like','%'.$phone.'%'];	//根据生成批次筛选
		} 
		
		if(!empty($stime) && !empty($etime)){
    		$s=strtotime($stime);
			$e=strtotime($etime);
    		$map['ctime']=['between',[$s,$e]];
    	}elseif(!empty($stime)){
    		$s=strtotime($stime);
    		$map['ctime']=['EGT',$s];
    	}elseif(!empty($etime)){
    		$e=strtotime($etime);
			$map['ctime']=['ELT',$e];
    	}
		
    	$rel=Db::name('users')
		->where($map)
		->order('ctime desc,id desc')
		->paginate(10,false,['query'=>[
			'type'		=>$type,
			'phone'		=>$phone,
			'stime'		=>$stime,
			'etime'		=>$etime
		]]);
		$this->assign('data',$rel);
		$this->assign('page',$rel->render());
		$this->assign('empty',"<tr><td class='empty' colspan='10'>当前没有数据 </td></tr>");
		$this->assign(['type'=>$type,'phone'=>$phone,'stime'=>$stime,'etime'=>$etime]);
		return $this->fetch();
	}
	//租客列表
//	public function tenant_list(){
//		echo 1;
//	}
}
